//获取书籍信息
import axios from "axios";
import { ElMessage } from "element-plus";
import { ref } from "vue";
import { getCurrentInstance } from "vue";

export async function getBookInformation( id , proxy ) {
  console.log(id,proxy);
  try {
    const response = await proxy.$http.get("/api/book/info", {
      params: { id: id },
    });
    const book = response.data.data.book;
    // console.log(book);
    const isSuccess = response.data.success;
    const message = response.data.message;
    // console.log(response.data);
    if(isSuccess===false){
     ElMessage.error(message);
    }
    else{
      // ElMessage.success("获取成功");
      console.log(book);
      return book;
    }
  } catch (error) {
    console.error(`Error fetching ${id} books:`, error);
    return [];
  }
}
